#include "ordersystem.h"
#include <QDateTime>
#include <QTextStream>

QVector<Order> OrderSystem::queryOrdersByUserId(int user_id)
{
    // 模拟数据库查询结果，实际应用中应从数据库获取数据
    QVector<Order> orders;

    if (user_id == 1) {
        // 模拟订单数据
        QDateTime departure_time = QDateTime::fromString("2024-12-01 14:00:00",
                                                         "yyyy-MM-dd HH:mm:ss");
        QDateTime arrival_time = QDateTime::fromString("2024-12-01 16:30:00", "yyyy-MM-dd HH:mm:ss");
        QDateTime created_at = QDateTime::fromString("2024-12-01 12:00:00", "yyyy-MM-dd HH:mm:ss");
        QDateTime payment_time, refund_time;

        FlightInfo flight_info("MU1234",
                               "Beijing",
                               "Shanghai",
                               "Beijing Capital International Airport",
                               "Shanghai Pudong International Airport",
                               departure_time,
                               arrival_time,
                               "China Eastern Airlines",
                               "Boeing 737");

        orders.append(Order(201,
                            "MU1234",
                            "Economy",
                            500.0,
                            "Pending payment",
                            payment_time,
                            refund_time,
                            created_at,
                            flight_info));
    }

    return orders;
}
